home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / include / x11 / wcharint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-11  |  3.2 KB  |  89 lines

  1. /*
  2.  * $XConsortium: wcharint.h,v 1.11 91/06/26 13:54:07 rws Exp $
  3.  */
  4.  
  5. /*
  6.  * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
  7.  *                      and Nippon Telegraph and Telephone Corporation
  8.  * Copyright 1991 by the Massachusetts Institute of Technology
  9.  *
  10.  * Permission to use, copy, modify, distribute, and sell this software and its
  11.  * documentation for any purpose is hereby granted without fee, provided that
  12.  * the above copyright notice appear in all copies and that both that
  13.  * copyright notice and this permission notice appear in supporting
  14.  * documentation, and that the names of OMRON, NTT Software, NTT, and M.I.T.
  15.  * not be used in advertising or publicity pertaining to distribution of the
  16.  * software without specific, written prior permission. OMRON, NTT Software,
  17.  * NTT, and M.I.T. make no representations about the suitability of this
  18.  * software for any purpose.  It is provided "as is" without express or
  19.  * implied warranty.
  20.  *
  21.  * OMRON, NTT SOFTWARE, NTT, AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD
  22.  * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  23.  * AND FITNESS, IN NO EVENT SHALL OMRON, NTT SOFTWARE, NTT, OR M.I.T. BE
  24.  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
  25.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  26.  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  27.  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  28.  * 
  29.  *    Author: Li Yuhong    OMRON Corporation
  30.  *   
  31.  */
  32.  
  33. #ifndef    _MCHARINT_H_
  34. #define _MCHARINT_H_
  35.  
  36. #include <ctype.h>
  37. #ifndef _WCHARXLIB_
  38. #include "wchar.h"
  39. #endif
  40.  
  41. #ifndef WNULL
  42. typedef    unsigned long wchar;    /* must be unsigned 4-byte type, ISO10646 */
  43.  
  44. #define WNULL    0
  45. #endif
  46.  
  47. #define LATIN1_GROUP    0x20    /* Latin 1 Group# */
  48. #define LATIN1_PLANE    0x20    /* Latin 1 Plane# */
  49. #define LATIN1_ROW    0x20    /* Latin 1 Row#   */
  50.  
  51. #define SCRIPT1        0xffffff00
  52. #define SCRIPT2        0xffff0000
  53. #define CONTROLSCRIPT    0x00ffffff
  54. #define LATINSCRIPT    0x20202000
  55. #define HIRAGANASCRIPT  0x20202f00
  56. #define KATAKANASCRIPT  0x20202f80
  57. #define HANZISCRIPT    0x20308080
  58. #define KANJISCRIPT    0x20408080
  59. #define HANJASCRIPT    0x20508080
  60. #define CLPADPADPAD    0x00808080
  61. #define WCHARSPACE    0x20202020
  62.  
  63. #define PrivateZone    0x20203400    /* Private Use Zone */
  64. #define PrivateZoneLast    0x20203b00    /* Last row of Private Use Zone */
  65.  
  66. #define PrivatePlane    0x20e00000    /* Private Use Plane */
  67. #define PrivatePlaneLast 0x20ff0000    /* Last row of Private Use Plane */
  68. #define PrivatePlaneLastI11 (PrivatePlaneLast | 0x8080)
  69. #define PrivatePlaneLastI10 (PrivatePlaneLast | 0x8000)
  70.  
  71. #define    wgetgroup(wc)    ((unsigned char)(((wc) >> 24) & 0x000000ff))
  72. #define    wgetplane(wc)    ((unsigned char)(((wc) >> 16) & 0x000000ff))
  73. #define    wgetrow(wc)    ((unsigned char)(((wc) >>  8) & 0x000000ff))
  74. #define    wgetcell(wc)    ((unsigned char)((wc) & 0x000000ff))
  75.  
  76.  
  77. #define _Xiswcntrl(wc)   ( ((wc)==WNULL) || \
  78.                (((wc)&CONTROLSCRIPT)==CLPADPADPAD \
  79.                 && iscntrl(wgetgroup(wc)&0x7f)) )
  80.  
  81. #define _Xatowc(c)    ( ((c)=='\0') ? WNULL: \
  82.              (iscntrl((c)&0x7f)) ? (((wchar)(c)<<24)|CLPADPADPAD): \
  83.                           (LATINSCRIPT|(c)) )
  84. #define _Xwctoa(wc)    ( _Xiswcntrl(wc) ? wgetgroup(wc): \
  85.              (((wc)&SCRIPT1)==LATINSCRIPT) ? wgetcell(wc): \
  86.                         (-1) )
  87.  
  88. #endif /* _MCHARINT_H_ */
  89.